#ifndef SERIAL_HPP_
#define SERIAL_HPP_

#include <fcntl.h>
#include <linux/serial.h>
#include <sys/ioctl.h>
#include <termios.h>

#include <mutex>
#include <string>
#include <vector>

#include "config.hpp"

class Serial {
  public:
    Serial(const std::string &serial_port);
    ~Serial();
    bool Open(const int &baudrate_code);
    bool Open();
    bool Close();
    bool ReadFromIO(std::vector<uint8_t> &data);
    bool WriteToIO(const std::vector<uint8_t> &data);
    bool WriteToIO(const char *cmd);
    int fd_{-1};

  private:
    std::string serial_port_;
    // std::mutex mutex_;
};

#endif